class Solution(object):
    def canMakePaliQueries(self, s, queries):
        n = len(s)
        prefix = [[0 for _ in range(26)] for _ in range(n)]
        for index, c in enumerate(s):
            for i in range(26):
                if index == 0:
                    prefix[index][i] = int(i == ord(c) - ord('a'))
                else:
                    prefix[index][i] = prefix[index - 1][i] + int(i == ord(c) - ord('a'))
        m = len(queries)
        out = [False for _ in range(m)]
        for index, (start, end, k) in enumerate(queries):
            c = 0
            for i in range(26):
                if start == 0:
                    c += prefix[end][i] % 2
                else:
                    c += (prefix[end][i] - prefix[start - 1][i]) % 2
            out[index] = c // 2 <= k
        return out


data = Solution()
s = "abcda"
queries = [[3,3,0],[1,2,0],[0,3,1],[0,3,2],[0,4,1]]
print(data.canMakePaliQueries(s, queries))